package guda.house.web.action.sys;

import guda.grape.autogen.common.page.BaseQuery;
import guda.grape.util.RequestUtil;
import guda.house.dal.dao.SuiteOutUserRelDAO;
import guda.house.dal.dataobject.SuiteOutUserRelDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by well on 16/3/6.
 */
@Controller
public class BindUserAction {

    @Autowired
    private SuiteOutUserRelDAO suiteOutUserRelDAO;

    @RequestMapping(value = "sys/bindUser/list.htm", method = RequestMethod.GET)
    public String list(HttpServletRequest request, ModelMap modelMap) {
        int pageId = RequestUtil.getInt(request, "pageNo");
        int pageSize = RequestUtil.getInt(request, "pageSize");
        BaseQuery baseQuery = new BaseQuery();
        baseQuery.setPageNo(pageId);
        baseQuery.setPageSize(pageSize);
        modelMap.put("query", baseQuery);
        List<SuiteOutUserRelDO> suiteOutUserRelDOs = suiteOutUserRelDAO.selectForPage(baseQuery);
        int count = suiteOutUserRelDAO.countForPage(baseQuery);
        baseQuery.setTotalCount(count);
        modelMap.put("suiteOutUserRelList", suiteOutUserRelDOs);
        return "sys/bindUser/list.vm";

    }
}
